# coding:utf8
from flask import Flask, render_template
from flask_sqlalchemy import SQLAlchemy

import pymysql

# 连接数据库
app = Flask(__name__)
app.config[
    "SQLALCHEMY_DATABASE_URI"
] = "mysql+pymysql://root:123456@192.168.12.38:3306/movie"
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
app.config["SECRET_KEY"] = "67340ce1017e4333875e4e149a98db62"
# app = Flask(__name__)

app.debug = True

db = SQLAlchemy(app)

from app.home import home as home_blueprint
from app.admin import admin as admin_blueprint

app.register_blueprint(home_blueprint)
app.register_blueprint(admin_blueprint, url_prefix="/admin")


@app.errorhandler(404)
def page_not_found(error):
    """
    404页面
    :param error:
    :return:
    """
    return render_template("home/404.html"), 404
